package com.jindianjichi.basic.service.impl;

import com.jindianjichi.basic.entity.SubjectCategory;
import com.jindianjichi.basic.mapper.SubjectCategoryDao;
import com.jindianjichi.basic.service.SubjectCategoryService;
import com.jindianjichi.subject.common.enums.IsDeletedEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;


import javax.annotation.Resource;
import java.util.Collections;
import java.util.List;

import static com.jindianjichi.subject.common.enums.IsDeletedEnum.UN_DELETED;

/**
 * 题目分类(SubjectCategory)表服务实现类
 *
 * @author makejava
 * @since 2024-11-15 22:47:56
 */
@Slf4j
@Service
public class SubjectCategoryServiceImpl implements SubjectCategoryService {
    @Resource
    private SubjectCategoryDao subjectCategoryDao;



    //根据条件查询分类数据
    public List<SubjectCategory> queryAllByLimit(SubjectCategory subjectCategory) {
        log.info("com.jindianjichi.basic.service.impl.SubjectCategoryServiceImpl.queryAllByLimit:{}", subjectCategory);
        subjectCategory.setIsDeleted(IsDeletedEnum.UN_DELETED.getCode());
        List<SubjectCategory> list = subjectCategoryDao.queryAllByLimit(subjectCategory);
        return list;
    }


    /**
     * 新增数据
     *
     * @param subjectCategory 实例对象
     * @return 实例对象
     */
    @Override
    public SubjectCategory insert(SubjectCategory subjectCategory) {
        this.subjectCategoryDao.insert(subjectCategory);
        return subjectCategory;
    }

    /**
     * 逻辑删除数据
     *
     * @param subjectCategory 实例对象
     * @return 实例对象
     */
    @Override
    public Integer deleteCategory(SubjectCategory subjectCategory) {
        Integer count=subjectCategoryDao.update(subjectCategory);
        return count;
    }

    @Override
    public SubjectCategory queryById(String categoryId) {
       SubjectCategory subjectCategory= subjectCategoryDao.queryById(categoryId);
        return subjectCategory;
    }

    @Override
    public Integer querySubjectCount(Long id) {
        return subjectCategoryDao.querySubjectCount(id);

    }


}
